package org.eclipse.php.internal.compiler.lookup;

/**
 * @author Sean.Quinn
 */
public abstract class Binding {

	// binding kinds
	//	public static final int VARIABLE = ASTNode.VARIABLE;
	//	public static final int METHOD = ASTNode.FUNCTION_NAME;
	//	public static final int NAMESPACE = ASTNode.NAMESPACE;
	//	public static final int USE = ASTNode.USE_STATEMENT;

	// Shared binding collections
	//	public static final ReferenceBinding[] NO_EXCEPTIONS = new ReferenceBinding[0];
	//	public static final ReferenceBinding[] ANY_EXCEPTION = new ReferenceBinding[] { null }; // special handler for all exceptions
	//	public static final FieldBinding[] NO_FIELDS = new FieldBinding[0];
	//	public static final MethodBinding[] NO_METHODS = new MethodBinding[0];
	//	public static final ReferenceBinding[] NO_SUPERINTERFACES = new ReferenceBinding[0];
	//	public static final ReferenceBinding[] NO_MEMBER_TYPES = new ReferenceBinding[0];

	//	public static final FieldBinding[] UNINITIALIZED_FIELDS = new FieldBinding[0];
	//	public static final MethodBinding[] UNINITIALIZED_METHODS = new MethodBinding[0];
	//	public static final ReferenceBinding[] UNINITIALIZED_REFERENCE_TYPES = new ReferenceBinding[0];

	/*
	 * Answer the receiver's binding type from Binding.BindingID.
	 */
	public abstract int kind();

	/*
	 * Computes a key that uniquely identifies this binding. Returns null if
	 * binding is not a TypeBinding, a MethodBinding, a FieldBinding or a
	 * PackageBinding.
	 */
	public char[] computeUniqueKey() {
		return computeUniqueKey(true/* leaf */);
	}

	/*
	 * Computes a key that uniquely identifies this binding. Optionally include
	 * access flags. Returns null if binding is not a TypeBinding, a
	 * MethodBinding, a FieldBinding or a PackageBinding.
	 */
	public char[] computeUniqueKey(boolean isLeaf) {
		return null;
	}

	/**
	 * Compute the tag bits for @Deprecated annotations, avoiding resolving
	 * entire annotation if not necessary.
	 *
	 * @see org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding#initializeDeprecatedAnnotationTagBits()
	 */
	public void initializeDeprecatedAnnotationTagBits() {
	// empty block
	}

	/*
	 * API Answer true if the receiver is not a problem binding
	 */
	public final boolean isValidBinding() {
		return problemId() == ProblemReasons.NoError;
	}

	/*
	 * API Answer the problem id associated with the receiver. NoError if the
	 * receiver is a valid binding. Note: a parameterized type or an array type
	 * are always valid, but may be formed of invalid pieces.
	 */
	// TODO (philippe) should rename into problemReason()
	public int problemId() {
		return ProblemReasons.NoError;
	}

	/*
	 * Answer a printable representation of the receiver.
	 */
	public abstract char[] readableName();

	/*
	 * Shorter printable representation of the receiver (no qualified type)
	 */
	public char[] shortReadableName() {
		return readableName();
	}
}
